/* ###################################### */
/* ###     Frost Engine, by Kalith    ### */
/* ###################################### */
/*               Lua source               */
/*                                        */


#include "EngineLua.h"
#include "../Engine.h"
/*
#include "gui/frost_uiobject.h"
#include "gui/frost_frame.h"
#include "gui/frost_layeredregion.h"
#include "gui/frost_button.h"
#include "gui/frost_editbox.h"
#include "gui/frost_scrollingmessageframe.h"
#include "gui/frost_slider.h"
#include "gui/frost_statusbar.h"
#include "gui/frost_fontstring.h"
#include "gui/frost_texture.h"
#include "unit/frost_unitmanager.h"
#include "unit/frost_unit.h"
#include "unit/frost_character.h"
#include "unit/frost_creature.h"
#include "scene/frost_movableobject.h"
#include "gameplay/frost_gameplay.h"
*/

//using namespace std;

namespace Engine
{
    namespace Lua
    {
		void RegisterGlobalFuncs( Util::Ptr<Util::Lua::State> pLua )
		{
			pLua->Register("GetLocale", l_GetLocale);
			pLua->Register("GetLocalizedString", l_GetLocalizedString);
			pLua->Register("GetTime", l_GetTime);
			pLua->Register("GetTimeOfTheDay", l_GetTimeOfTheDay);
			pLua->Register("Exit", l_Exit);
		}

		void RegisterGUIClasses( Util::Ptr<Util::Lua::State> pLua )
		{
			/*
			pLua->Register<GUI::LuaUIObject>();
			pLua->Register<GUI::LuaFrame>();
			pLua->Register<GUI::LuaStatusBar>();
			pLua->Register<GUI::LuaEditBox>();
			pLua->Register<GUI::LuaScrollingMessageFrame>();
			pLua->Register<GUI::LuaButton>();
			pLua->Register<GUI::LuaSlider>();
			pLua->Register<GUI::LuaLayeredRegion>();
			pLua->Register<GUI::LuaTexture>();
			pLua->Register<GUI::LuaFontString>();
			*/
		}

		void RegisterUnitClass( Util::Ptr<Util::Lua::State> pLua )
		{
			/*
			pLua->Register<LuaUnitManager>();
			UnitManager::GetSingleton()->CreateGlue(pLua);
			pLua->Register<LuaUnit>();
			pLua->Register<LuaMovableUnit>();
			pLua->Register<LuaCharacter>();
			pLua->Register<LuaCreature>();
			*/
		}

		void RegisterMovableObjectClass( Util::Ptr<Util::Lua::State> pLua )
		{
			//pLua->Register<LuaMovableObject>();
		}

		void RegisterGameplayClass( Util::Ptr<Util::Lua::State> pLua )
		{
			//pLua->Register<LuaGameplay>();
		}

		void RegisterVectorClass( Util::Ptr<Util::Lua::State> pLua )
		{
			pLua->DoFile("DB/Vector.lua");
		}

		void RegisterKeyCodes( Util::Ptr<Util::Lua::State> pLua )
		{
			pLua->DoFile("DB/KeyCodes.lua");
		}
	}

	int l_GetLocale( lua_State* pLua )
	{
		Util::Lua::Function mFunc("GetLocale", pLua, 1);

//		mFunc.Push(LocaleManager::GetSingleton()->GetLocale());

		return mFunc.Return();
	}

	int l_GetLocalizedString( lua_State* pLua )
	{
		Util::Lua::Function mFunc("GetLocalizedString", pLua, 1);
		mFunc.Add(0, "string id", Util::Lua::TYPE_STRING);
		if (mFunc.Check())
		{
			Util::Str sID = mFunc.Get(0)->GetString();
			//mFunc.Push(LocaleManager::GetSingleton()->GetLocalizedString(sID));
		}

		return mFunc.Return();
	}

	int l_GetTime( lua_State* pLua )
	{
		Util::Lua::Function mFunc("GetTime", pLua, 1);

		mFunc.Push(Util::TimeManager::GetSingleton()->GetTime());

		return mFunc.Return();
	}

	int l_GetTimeOfTheDay( lua_State* pLua )
	{
		Util::Lua::Function mFunc("GetTimeOfTheDay", pLua, 4);

		mFunc.Push(Util::TimeManager::GetSingleton()->GetHour());
		mFunc.Push(Util::TimeManager::GetSingleton()->GetMinutes());
		mFunc.Push(Util::TimeManager::GetSingleton()->GetSeconds());
		mFunc.Push(Util::TimeManager::GetSingleton()->GetMicroseconds());

		return mFunc.Return();
	}

	int l_Exit( lua_State* pLua )
	{
		Util::Lua::Function mFunc("Exit", pLua);

		Engine::GetSingleton()->ShutDown();

		return mFunc.Return();
	}
}